package com.megvii.koala.data.bean;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.megvii.corelib.data.BaseBean;
import com.megvii.corelib.util.DateTimeUtil;
import com.megvii.koala.data.UrlMaker;

/**
 * Created by linyue on 16/1/7.
 */
public class RecognizeBean extends BaseBean
{
    public float confidence;

    public String tag;

    public RecognizePerson decodedTag;

    public void decodeTag(UrlMaker urlMaker)
    {
        try
        {
            ObjectMapper mapper = new ObjectMapper();
            mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
            decodedTag = mapper.readValue(tag, RecognizePerson.class);
            //
            decodedTag.avatar = urlMaker.makeUrl(decodedTag.avatar);
            decodedTag.start_time = DateTimeUtil.toMSTimestamp(decodedTag.start_time);
            decodedTag.end_time = DateTimeUtil.toMSTimestamp(decodedTag.end_time);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}
